package Commandes;

import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import projetjava.ApercuPhotoGrand;




public class Commande_Zoom implements Commande{
    
    
    private ApercuPhotoGrand apg;
    private String zoom;
    
    public Commande_Zoom(ApercuPhotoGrand apg,String zoom) {
        this.zoom=zoom;
        this.apg=apg;
        
    }
    
    public boolean executer() {
        
        this.zoomer(this.zoom);
        return false;
    }
    
    public boolean cancel() {
        
        return false;
    }
    
    
    public void zoomer(String zoom){
        if(zoom=="+") {
            AffineTransform at = new AffineTransform();
            at.scale(apg.getApercu().getWidth()*1.5, apg.getApercu().getWidth()*1.5);
            AffineTransformOp atOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC);
            BufferedImage dimg = new BufferedImage(apg.getApercu().getWidth(), apg.getApercu().getHeight(),BufferedImage.TYPE_INT_ARGB);
            atOp.filter(apg.getApercu(), dimg);
            apg.setApercu(dimg);
        }else{
            
        }
    }
}
